#include "mb_webview.h"

mb_webview::mb_webview(const QUrl &url)
{
     page.mainFrame()->load(url);
     connect(&page, SIGNAL(loadFinished(bool)),
         this, SLOT(render()));     
}

void mb_webview::render()
{
    page.setViewportSize(page.mainFrame()->contentsSize());
    QImage image(page.viewportSize(), QImage::Format_ARGB32);
    QPainter painter(&image);

    page.mainFrame()->render(&painter);
    painter.end();

    QImage thumbnail = image.scaledToWidth(1024);
    thumbnail.save("thumbnail.png");

    emit finished();
}
